#ifndef ZIMINGXIAYICONTEXT_H
#define ZIMINGXIAYICONTEXT_H

#include <QObject>
#include <memory>

#include "ViewModels/MainContentViewModel.h"

class ZimingxiayiContext : public QObject
{
    Q_OBJECT

public:
    explicit ZimingxiayiContext(QObject *parent = 0);

public:
    virtual ~ZimingxiayiContext(){}

    static ZimingxiayiContext * Context()
    {
        Q_ASSERT(_context);
        return _context;
    }

    static void SetContext(ZimingxiayiContext * context)
    {
        // 设置单例
        _context = context;
    }

    void Initialize();

    std::shared_ptr<MainContentViewModel> MainContent() const { return _mainViewModel; }

public:
    void setDataRaw(unsigned char *data, int length)
    {
        if(_dataRaw != nullptr) delete _dataRaw;
        _dataRaw = new unsigned char[length];

        memcpy(_dataRaw, data, length);
    }

private:
    static ZimingxiayiContext *_context; // 上下文
    std::shared_ptr<MainContentViewModel> _mainViewModel; // 主窗体 View Model

    unsigned char *_dataRaw;
};

extern "C" __declspec(dllexport) ZimingxiayiContext * CreateContext();

#endif // ZIMINGXIAYICONTEXT_H
